{extend name="public/common"}

{block name="style"}
<title>点对点教育VIP学员_每日一句</title>
<link rel="stylesheet" href="__HOME__/css/word/detail.css">
<link rel="stylesheet" href="__HOME__/css/word/APlayer.min.css">
<style>
    .rep_main {
        width: 100%;
        padding: 3.4vw 3.4vw 2vw 3.4vw;
        overflow-x: hidden;
    }
    .manager.after {
        display: inline-block;
        position: fixed;
        bottom: 68px;
        right: 10px;
        content: '';
        width: 12.4vw;
        height: 12.4vw;
        background: url(__HOME__/images/common/news.png) no-repeat;
        background-color: #fff;
        background-size: 100% 100%;
        opacity: 1;
        -webkit-animation: cir2 0.5s ease-in;
        animation: cir2 0.5s ease-in;
        z-index: 99;
    }
    .de{
        font-size: 1.8rem;
        margin:5vw auto auto 15vw;
    }
    .img{
        width: 50vw;
        margin: 30vw auto auto 22vw;
    }
    .rep_main .info {
        font-size: 1.8rem;
        color: #333;
        padding: 0 1vw;
        text-align: justify;
        width: 100%;
        overflow: hidden;
    }
    .work-descri{
        padding: 2vw 5vw;
    }

    .work-descri div{
        margin-top: 15px;
        font-size: 1.5rem;
        color: #666;
        width: 100%;
        line-height: 2.5rem;
        word-wrap: break-word;
    }
    .but{
        text-align: center;
    }
    .but span{
        display: inline-block;
        background: #09a536;
        color: #fff;
        font-size: 1.5rem;
        font-family: "微软雅黑";
        width:25.2vw;
        height:3rem;
        line-height:3rem;
        text-align: center;
        border-radius: 5px;
    }
    .loading {
        background: url("__HOME__/images/common/loading.png") center no-repeat;
        background-size: 10.8vw 10.8vw;
        position: fixed;
        left: 50%;
        top: 50%;
        z-index: 101;
        width: 10.8vw;
        height: 10.8vw;
        margin-left: -5.4vw;
        margin-top: -5.4vw;
        animation: rotate 2s ease infinite;
        display: none;
    }
    .span{
        font-size: 1.6rem;
        color: #333;
        font-family: "黑体";
        font-weight: bold;
        padding-bottom: 5px;
        border-bottom: 1px solid #6f5757;
    }
</style>
{/block}
{block name="body"}
<div class="scrollDiy" data-id="0">
    {eq name="$is" value="0"}
    <img class="img" src="__ADMIN__/images/logo.png">
    <div class="de">抱歉~~今日暂无内容，请等待！</div>
    {else/}
    <div class="rep_main">
        <div class="title">{$info.title}</div>
        <div class="note clear">
            <span class="fls">点对点教育</span>
            <span class="frs">{$info.create_time}</span>
        </div>
        <div class="info">
            　{$info.content}
        </div>
    </div>
    <div class="work-descri">
        {empty name="info.answer"}
        <div>
            <span class="span">翻译内容</span>
            <textarea style="font-size: 1.5rem;border: 1px solid #cccccc;width: 100%;padding: 2vw" placeholder=" *此处填写内容..." name="answer" rows="8"></textarea>
            <div class="but">
                <span>提交</span>
            </div>
        </div>
        {else/}
        <div>
            <span class="span">翻译内容</span>
            <textarea style="font-size: 1.5rem;border: 1px solid #cccccc;width: 100%;padding: 2vw" rows="8" disabled>{$info.answer}</textarea>
            <span class="span">老师批语</span>
            <textarea style="font-size: 1.5rem;border: 1px solid #cccccc;width: 100%;padding: 2vw" rows="8" disabled>{$info.result}</textarea>
        </div>
        {/empty}
    </div>
    {/eq}
</div>
<div class="loading"></div>
<a href="{:Url('Translate/personal')}" class="after manager" id="publish"></a>
{/block}


{block name="script"}
<script src="__HOME__/js/reset.js"></script>
<script src="__HOME__/js/APlayer.min.js"></script>
<script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
    //关闭分享
    function onBridgeReady() {
        WeixinJSBridge.call('hideOptionMenu');
    }
    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    } else {
        onBridgeReady();
    }
    $('title').text('点对点教育VIP学员_每日一句');
    $(function(){
        if(document.getElementById("publish")){
            moveanyway("publish");
        }
    })
    $(".but").click(function() {
        var answer = $("textarea[name='answer']").val();
        answer = utf16toEntities(answer);
        if (answer == '' || answer == null) {
            swal({
                title: ' ',
                text: '输入内容才可以提交哦~',
                type: 'error',
                allowOutsideClick :false,
                confirmButtonText: '确定'
            });
            return false;
        }
        var id = "{$info.id}";
        var userid = "{$info.userid}";
        $.ajax({
            type: "post",
            url: "{:Url('Translate/sign')}",
            data: {
                answer: answer,
                id:id,
                userid:userid
            },
            beforeSend: function (XMLHttpRequest) {
                $(".loading").show();
            },
            success: function (data) {
                $(".loading").hide();
                if (data.code == 1) {
                    swal({
                        title: ' ',
                        text: '提交成功',
                        type: 'success',
                        confirmButtonText: '确定',
                        allowOutsideClick :false,
                        timer: 1500
                    },function(){
                        window.location.reload();
                    });
                } else {
                    swal({
                        title: ' ',
                        text: '提交失败，请重试',
                        allowOutsideClick :false,
                        type: 'error',
                        confirmButtonText: '确定',
                        timer: 1500
                    })
                }
            }
        })

    });
    /**
     * 用于把用utf16编码的字符转换成实体字符，以供后台存储
     * @param  {string} str 将要转换的字符串，其中含有utf16字符将被自动检出
     * @return {string}     转换后的字符串，utf16字符将被转换成&#xxxx;形式的实体字符
     */
    function utf16toEntities(str) {
        var patt=/[\ud800-\udbff][\udc00-\udfff]/g; // 检测utf16字符正则
        str = str.replace(patt, function(char){
            var H, L, code;
            if (char.length===2) {
                H = char.charCodeAt(0); // 取出高位
                L = char.charCodeAt(1); // 取出低位
                code = (H - 0xD800) * 0x400 + 0x10000 + L - 0xDC00; // 转换算法
                return "&#" + code + ";";
            } else {
                return char;
            }
        });
        return str;
    }
</script>
{/block}